Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix interaction between unread and mark #208

Merged
merged 3 commits into from
May 4, 2024
Merged

Fix interaction between unread and mark #208

merged 3 commits into from
May 4, 2024

Conversation

nhz2
Copy link
Member

@nhz2 nhz2 commented May 4, 2024

On master

julia> using TranscodingStreams

julia> stream = NoopStream(IOBuffer("foobar"));

julia> mark(stream)
0

julia> read(stream, String)
"foobar"

julia> TranscodingStreams.unread(stream, b"bar")

julia> reset(stream)
-3

julia> read(stream, String)
"foobarbar"

With this PR:

julia> using TranscodingStreams

julia> stream = NoopStream(IOBuffer("foobar"));

julia> mark(stream)
0

julia> read(stream, String)
"foobar"

julia> TranscodingStreams.unread(stream, b"bar")

julia> reset(stream)
0

julia> read(stream, String)
"foobar"

@nhz2 nhz2 force-pushed the nz/unread-and-mark branch from ed2d0b8 to c61e12e Compare May 4, 2024 19:32
min(buf.markpos, buf.bufferpos)
end
datasize = buf.marginpos - datapos
copyto!(buf.data, datapos + nbytes, buf.data, datapos, datasize)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes ensure the marked data and buffered data stay together.

@nhz2 nhz2 marked this pull request as ready for review May 4, 2024 20:07
@nhz2 nhz2 requested review from mkitti and jakobnissen May 4, 2024 20:14
Copy link
Member

@mkitti mkitti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks food. I'm not sure if we should be using @Assert so much

@nhz2 nhz2 merged commit 8fdabed into master May 4, 2024
26 checks passed
@nhz2 nhz2 deleted the nz/unread-and-mark branch May 4, 2024 22:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants